package org.millioncall.yueyoga.common.utils;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.millioncall.openplatform.util.ServletUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AjaxUtils {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(AjaxUtils.class);

	public static void ajaxResponse(HttpServletResponse response, String content) {
		response.setContentType("application/json;charset=UTF-8");
		// 设置缓存失效
		ServletUtils.setDisableCacheHeader(response);
		PrintWriter out = null;
		try {
			out = response.getWriter();
			out.print(content);
		} catch (IOException e) {
			LOGGER.error("IO异常", e);
		} finally {
			out.flush();
			out.close();
		}
	}
}
